<?php

namespace App\Providers;

use App\Models\AdTask;
use App\Models\AppleTask;
use App\Models\Task;
use App\Observers\AppleTaskObserver;
use App\Observers\ConfigObserver;
use App\Observers\TaskAdObserver;
use App\Observers\TaskObserver;
use Encore\Admin\Config\Config;
use Encore\Admin\Config\ConfigModel;
use Illuminate\Support\Facades\Redis;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        Config::load();
        Task::observe(TaskObserver::class);
        AdTask::observe(TaskAdObserver::class);
        ConfigModel::observe(ConfigObserver::class);

        app('redis')->select(REDIS_DB);
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
        if ($this->app->environment() !== 'production') {
            $this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class);
        }
    }
}
